using System;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CBaseQueryInfo : CBaseTable
    {
        //
        public const string ENTITY_NAME = "tb_sys_query_info";
        public const string ENTITY_ALIAS = "query";
        public const string ENTITY_KEY = "query_id";
        public const string ENTITY_SYMBOL = "query_name";
        //
        public const string USER_ID = CBaseUserInfo.ENTITY_KEY;
        public const string ITEM_PATH = "item_path";
        public const string ITEM_VALUE = "item_value";
        public const string ITEM_ARGS = "item_args";
        public const string ITEM_ORIGIN = "item_origin";
        public const string ITEM_NOTE = "item_note";
        public const string ITEM_REVIEW = "item_review";
        public const string ITEM_SIZE = "item_size";
        //
        private SBaseQueryInfo _ = null;
        //
        public CBaseQueryInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseQueryInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CBaseQueryInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CBaseQueryInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SBaseQueryInfo());
        }
        protected void SetSchema(SBaseQueryInfo s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            this._DataTable.Columns.Add(USER_ID, typeof(long)).DefaultValue = this._.UserID;
            this._DataTable.Columns.Add(ITEM_PATH, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(ITEM_VALUE, typeof(string)).MaxLength = 1024;
            this._DataTable.Columns.Add(ITEM_ARGS, typeof(string)).MaxLength = 1024;
            this._DataTable.Columns.Add(ITEM_ORIGIN, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(ITEM_NOTE, typeof(string)).MaxLength = 256;
            this._DataTable.Columns.Add(ITEM_REVIEW, typeof(int)).DefaultValue = this._.ItemReview;
            this._DataTable.Columns.Add(ITEM_SIZE, typeof(int)).DefaultValue = this._.ItemSize;
        }
        //
        #region Property
        //
        public long UserID
        {
            set
            {
                this._.UserID = value;
                this.SetValue(USER_ID, value);
            }
            get
            {
                return this._.UserID;
            }
        }
        //
        public string ItemPath
        {
            set
            {
                this._.ItemPath = value;
                this.SetValue(ITEM_PATH, value);
            }
            get
            {
                return this._.ItemPath;
            }
        }
        //
        public string ItemValue
        {
            set
            {
                this._.ItemValue = value;
                this.SetValue(ITEM_VALUE, value);
            }
            get
            {
                return this._.ItemValue;
            }
        }
        //
        public string ItemArgs
        {
            set
            {
                this._.ItemArgs = value;
                this.SetValue(ITEM_ARGS, value);
            }
            get
            {
                return this._.ItemArgs;
            }
        }
        //
        public string ItemOrigin
        {
            set
            {
                this._.ItemOrigin = value;
                this.SetValue(ITEM_ORIGIN, value);
            }
            get
            {
                return this._.ItemOrigin;
            }
        }
        //
        public string ItemNote
        {
            set
            {
                this._.ItemNote = value;
                this.SetValue(ITEM_NOTE, value);
            }
            get
            {
                return this._.ItemNote;
            }
        }
        //
        public int ItemReview
        {
            set
            {
                this._.ItemReview = value;
                this.SetValue(ITEM_REVIEW, value);
            }
            get
            {
                return this._.ItemReview;
            }
        }
        //
        public int ItemSize
        {
            set
            {
                this._.ItemSize = value;
                this.SetValue(ITEM_SIZE, value);
            }
            get
            {
                return this._.ItemSize;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.UserID = this.GetValue<long>(USER_ID);
            this._.ItemPath = this.GetValue<string>(ITEM_PATH);
            this._.ItemValue = this.GetValue<string>(ITEM_VALUE);
            this._.ItemArgs = this.GetValue<string>(ITEM_ARGS);
            this._.ItemOrigin = this.GetValue<string>(ITEM_ORIGIN);
            this._.ItemNote = this.GetValue<string>(ITEM_NOTE);
            this._.ItemReview = this.GetValue<int>(ITEM_REVIEW);
            this._.ItemSize = this.GetValue<int>(ITEM_SIZE);
            return true;
        }
        //
    }
    //
    public class SBaseQueryInfo : SBaseTable
    {
        //
        public long UserID = -1;
        public string ItemPath = null;
        public string ItemValue = null;
        public string ItemArgs = null;
        public string ItemOrigin = null;
        public string ItemNote = null;
        public int ItemReview = 0;
        public int ItemSize = -1;
        //
    }
    //
}
//
